﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using DAL;
using models;

namespace BLL
{
    public class PayManager
    {
        PayService service = new PayService();
        //全部总价显示
        public Pay SumCart(string id,string ddh)
        {
            Pay user = null;
            SqlDataReader reader = service.SumCart(id, ddh);
            while (reader.Read())
            {
                if (reader.IsDBNull(0))
                {
                    user = new Pay(
                        0
                        );
                }
                else
                {
                    user = new Pay(
                 reader.GetDecimal(0)
                 );
                }
              
                  
                



            }

            DBhelper.Close();
            return user;
        }
        public bool add(Pay pay)
        {
            return service.add(pay);
        }
        //查询出Pay表中所需要的信息
        public List<Pay> SelPay(string id ,string ddh)
        {
            List<Pay> pays = new List<Pay>();
            SqlDataReader reader = service.SelPay(id,ddh);
            while (reader.Read())
            {
                pays.Add(new Pay(

                        reader.GetDecimal(0),//
                        reader.GetInt32(1),//
                        reader.GetInt32(2),//
                        reader.GetString(3),//
                        reader.GetString(4),//
                        reader.GetString(5),//
                        reader.GetDecimal(6),//
                        reader.GetInt32(7),//
                        reader.GetString(8),//
                        reader.GetInt32(9),//
                        reader.GetString(10),//
                        reader.GetString(11)//
                    ));
            }
            DBhelper.Close();
            return pays;
        }

    }

}
